home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
misc_pto
/
29ksim
/
demo.s
< prev
next >
Wrap
Text File
|
1987-11-30
|
4KB
|
186 lines
.title "Demo.s -- Test file for 29K-Soft"
;********************************************************************
; Am29000 Demonstratio Software Version 1.0
;*********************************************************************
.global main
.nolistmx
.nolistsym
.nolisttx
.nolistix
.include "trap.h"
.include "sr.h"
.include "macro.h"
PUTSTR .macro straddr ; Get pointer to memory buffer
const gr60,straddr
call gr5b,puts
consth gr60,straddr>>16
.endm
GETSTR .macro straddr,endaddr ; Get pointer to memory buffer
const gr60,straddr
consth gr60,straddr>>16
const gr5f,(endaddr-4)
call gr5b,gets
consth gr5f,(endaddr-4)>>16
.endm
; .list
data .seg data,absolute 6000#h ; memory
.use data
String1:
.textz "\n\n\n\n\n\n\n\nAm29000 Demo Program\n\n\n\n\n\nWelcome to the world of 17+MIPS demo'ed at .0001 MIPS\n\n\nWhat is your name? "
.align
Response:
.textz "\n\nImagine this running 170,000 times faster, "
.align
Pressany:
.textz "\n\nPress Any Key"
.align
Keybuff:
.block 128
KeyEnd:
.word 0
code .seg code,absolute 01000#h /* */
.use code
no .equ 20#h ;control byte for load or store no xlate in super mode
yes .equ 0 ;control byte for load or store xlate ok
lsbyte .equ 30#h ;control for load or store to set Byte Pointer, no xlate
LOOPCOUNT .equ 500 ; counter through loop
; This is a simple demo program to test the simulator I/O ability.
;
;;;;;;;;;;;;;;;;;;;;
main:
;;;;;;;;;;;;;;;;;;;;
.listmx
PUTSTR String1
GETSTR Keybuff,KeyEnd
PUTSTR Response
PUTSTR Keybuff
PUTSTR Pressany
getchar
putchar 13
putchar 10
putchar 10
trap END_SUCCESS ;all tests completed, no errors
;;;;;;;;;;;;;;;
error:
;;;;;;;;;;;;;;;
trap END_FAIL ; failed something
nop
nop
;;;;;;;;;;;;;;;;
gets:
/*
Enter with gr60 pointing at start of buffer and gr5f pointing at end.
Rignt not must start on even word boundry !!!
Should be rewritten to use Byte Pointer loading bit in load store and
use BP register and not ALU status.
*/
;;;;;;;;;;;;;;;;
const gr55,0 ; initialize byte counter/pointer
add gr57,gr60,0 ; make copy of pointer
gsloop:
load lsbyte,gr58,gr60 ; give lots of time!
; set up for byte insert instruction - just to use it and learn it!
getchar ; returned as byte in gr02
asneq PUTCHAR,gr01,gr01 ; echo
and gr41,gr02,0ff#h ; clear all but lower byte
cpeq gr54,gr41,0d#h ; compare with carriage return!
jmpf gr54,noterm ; no, so continue
nop
putchar 13
putchar 10
const gr41,0 ; terminate with a zero!
noterm:
inbyte gr58,gr58,gr41 ; stuff byte into word
store lsbyte,gr58,gr60 ; save it in keyboard buffer
jmpti gr54,gr5b ; Return if done
; Now to update pointer
cpge gr56,gr60,gr5f ; check for past buffer!
jmpf gr56,gsloop ; continue if not past!
add gr60,gr60,1 ; increment Byte Pointer
jmpi gr5b ; gets complete ok return to main
nop ; after jmpi !
;;;;;;;;;;;;;;;;
puts:
/* Called with gr60 pointing at string to print. Lowest two bits
select first byte
Should be rewritten to use Byte Pointer loading bit in load store.
*/
;;;;;;;;;;;;;;;;
load lsbyte,gr58,gr60 ; give lots of time!
add gr57,gr60,0 ; Make copy of pointer
const gr54,0 ; clear it for extracted byte
putloop:
; extract set up by previous load instruction
exbyte gr54,gr58,gr54 ; extract character from word
and gr54,gr54,0ff#h
cpeq gr56,gr54,0#h ; compare with zero termination
jmpti gr56,gr5b ; return
cpeq gr56,gr54,10 ; compare with Line Feed
jmpf gr56,notlf
putchar 13 ; put carriage return
; Now check for need to update pointer
; increment byte pointer
notlf:
add gr57,gr57,1 ; increment Byte Pointer
and gr55,gr57,11#b ; make sure not new word
cpeq gr56,gr55,0 ; check for overflow
jmpf gr56,oldword ; jump if old word
and gr02,gr54,0ff#h ; clear and move to gr02 for trap
load no,gr58,gr57 ; get new word and load BP manually
oldword:
mtsr BP,gr55
trap PUTCHAR ; trap to put character in gr02
jmp putloop
nop ; a couple more to make sure code seg
nop ; is big enough for simulator
.end